package com.vhr.controller;

public class SalaryController {
/**
    //计算月奖金:访问：http://localhost:8080/salary/monthBonus
    @RequestMapping(value = "/salary/monthBonus",method = RequestMethod.GET)
    public double monthBonus(Employee employee){
        employee.setEmpId(1);
        return iSalaryService.calculateMonthBonus(employee,8,2019);
    }

    //计算加班:访问：http://localhost:8080/salary/overtimeSalary
    @RequestMapping(value = "/salary/overtimeSalary",method = RequestMethod.GET)
    public double overtimeSalary(Employee employee){
        employee.setEmpId(1);
        return iSalaryService.calculateOvertimeSalary(employee,8,2019);
    }

    //计算请假扣款:访问：http://localhost:8080/salary/leaveFine
    @RequestMapping(value = "/salary/leaveFine",method = RequestMethod.GET)
    public double leaveFine(Employee employee){
        employee.setEmpId(1);
        return iSalaryService.calculateLeaveFine(employee,9,2019);
    }

    //计算迟到，旷工，早退扣款:访问：http://localhost:8080/salary/illegalFine
    @RequestMapping(value = "/salary/illegalFine",method = RequestMethod.GET)
    public double illegalFine(Employee employee){
        employee.setEmpId(2);
        return iSalaryService.calculateCheck(employee,9,2019);
    }

    //计算更改补贴方式，大于0是成功，0是失败:
    //访问：http://localhost:8080/salary/updateWelfare
    @RequestMapping(value = "/salary/updateWelfare",method = RequestMethod.GET)
    public int updateWelfare(Employee employee){
        employee.setEmpId(1);
        return iSalaryService.updateWelfare(employee,2);
    }

    //计算扣税
    //访问：http://localhost:8080/salary/tax
    @RequestMapping(value = "/salary/tax",method = RequestMethod.GET)
    public double tax(Employee employee){
        employee.setEmpId(1);
        return iSalaryService.calculateTax(7000.0,employee,9,2019);
    }

    //计算真实的薪水
    //访问：http://localhost:8080/salary/realSalary
    @RequestMapping(value = "/salary/realSalary",method = RequestMethod.GET)
    public double realSalary(Employee employee){
        employee.setEmpId(1);
        return iSalaryService.calculatePersonSalary(employee,9,2019);
    }
    */


/*
Employee employee = new Employee();
        employee.setEmpId(empId);

    String strdate = payTime+"-12";
    DateFormat datetext = DateFormat.getDateInstance();
    Date date = null;
        try {
        date = datetext.parse(strdate);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    int year = Integer.parseInt(payTime.substring(0,4));
    int month = date.getMonth()+1;
    //System.out.println("-----------------"+year+"--------------"+month);
    Calendar start = Calendar.getInstance();
        start.set(year,month-1,1,0,0,0);
    Calendar end = Calendar.getInstance();
        end.set(year, month,1,0,0,0);

    SalaryExample salaryExample = new SalaryExample();
    SalaryExample.Criteria criteria = salaryExample.createCriteria();
        criteria.andEmpIdEqualTo(employee.getEmpId()).andPayTimeBetween(start.getTime(),end.getTime());

        PageHelper.startPage(pageNum,pageSize);
    List<Salary> list = salaryMapper.selectByExample(salaryExample);

    PageInfo<Salary> pageInfo = new PageInfo<>(list);
        if(pageInfo.getList()==null){
        return Result.fail();
    }
    ArrayList<SalaryToPage> salaryVOList = new ArrayList<>();
    Salary salary = new Salary();
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");

    List<SalaryToPage> salaryToPages = iSalaryService.selectOneEmpSalary(employee);


        for(int i=0;i<list.size();i++){
        Salary s = list.get(i);
        SalaryToPage vo = new SalaryToPage();

        for(int n=0;n<salaryToPages.size();n++){
            if(list.get(i).getSalaryId()==salaryToPages.get(n).getId()){
                vo.setId(salaryToPages.get(n).getId());
                vo.setBasic(salaryToPages.get(n).getBasic());
                vo.setDate(salaryToPages.get(n).getDate());
                vo.setReal_salary(salaryToPages.get(n).getReal_salary());
                vo.setTex(salaryToPages.get(n).getTex());
                vo.setLeave(salaryToPages.get(n).getLeave());
                vo.setCheck(salaryToPages.get(n).getCheck());
                vo.setHouse(salaryToPages.get(n).getHouse());
                vo.setTravel(salaryToPages.get(n).getTravel());
                vo.setFood(salaryToPages.get(n).getFood());
                vo.setOverTime(salaryToPages.get(n).getOverTime());
                vo.setMonthBonus(salaryToPages.get(n).getMonthBonus());
                salaryVOList.add(vo);
            }
        }
    }
    MyPageInfo<SalaryToPage> myPageInfo = new MyPageInfo<>();
        myPageInfo.setList(salaryVOList);
        myPageInfo.setPageNum(pageNum);
        myPageInfo.setPageSize(pageSize);
        myPageInfo.setRecordCount((int) pageInfo.getTotal());
        myPageInfo.setTotalPage(pageInfo.getPages());
        return Result.success().add("list",myPageInfo);*/
}
